/**
 * 渲染“附件”元素到编辑器
 * https://www.wangeditor.com/v5/development.html#%E5%9C%A8%E7%BC%96%E8%BE%91%E5%99%A8%E4%B8%AD%E6%B8%B2%E6%9F%93%E6%96%B0%E5%85%83%E7%B4%A0
 */
function parseHtml(elem, children, editor) {
  const materialType = elem.getAttribute('data-material-type') || ''
  const videoId = elem.getAttribute('data-video-id') || ''
  const videoName = elem.getAttribute('data-video-name') || ''
  return {
    type: 'vod',
    materialType,
    videoId,
    videoName,
    children: [{ text: '' }] // node 必须有一个空白 text
  }
}

const parseHtmlConf = {
  selector: 'div[data-w-e-type="vod"]',
  parseElemHtml: parseHtml
}

export default parseHtmlConf
